package com.app.common.utils;

/**
 * 移位工具类
 * @author CCR
 * time 2014-10-2 
 */
public class MoveByteUtil {
	
	/**
	 * 
	 * @param oldHistory
	 * @param moveAmonut
	 * @return
	 */
	public static Long moveByte(long oldHistory,long moveAmonut)
    {
        long moveResult = oldHistory<<moveAmonut;
        long result =  Long.parseLong(toFullBinaryString(moveResult),2)+1;
        return result;
    }


    /**
     * 读取将long类型转成二进制字符串
     * @param num
     * @return 
     */
    private static String toFullBinaryString(long num) {
        final int size=42;
        char[] chs = new char[size];
        for(int i = 0; i < size; i++) {
            chs[size - 1 - i] = (char)(((num >> i) & 1) + '0');
        }
        return new String(chs);
    }
    
    public static void main(String args[]) {
    	System.out.println(toFullBinaryString(1));
		System.out.println(moveByte(0, 1));
	}

}
